#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <sys/un.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char ch = '1';
        int sockfd;
        struct sockaddr_un cliet_address;
        int cliet_len;
        cliet_len = sizeof(cliet_address);
    // 创建套接字
    sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
    // 绑定套接字
    cliet_address.sun_family = AF_UNIX;
    strcpy(cliet_address.sun_path, "server_socket");
    // 连接服务器
    int result = connect(sockfd, (struct sockaddr *)&cliet_address, cliet_len);
    if (result == -1)
    {
        printf("连接失败");
        return 0;
    }
    read(sockfd, &ch, 1);
    printf("char from server = %c\n", ch);
    close(sockfd);
    return 0;
}